<?php
/**
 * Created by PhpStorm.
 * User: UEWARE
 * Date: 2019-7-5
 * Time: 10:54:55
 */

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Crypt;

class LoginController extends Controller
{
    /**
     * LoginController constructor.
     */
    public function __construct()
    {
    }

    /**
     * 登录
     */
    public function index(Request $request)
    {
        $data = $request->input();

        if (empty($data['username'])) {
            return error(300, '请填写用户名');
        }

        if (empty($data['password'])) {
            return error(301, '请填写密码');
        }

        if(empty($admin)){
            return error(302, '密码或者账户错误');
        }

        $result['token'] = Crypt::encrypt($admin);

        return success($result);
    }
}